<?php
	header("Content-Type:application/json;charset=utf-8");
	require_once("init.php");

	$output=[
		"recordCount"=>0,//满足条件的结果总数
		"pageSize"=>2,//每页显示的行数
		"pageCount"=>0,//显示的页数
		"pno"=>1,     //页数
		"data"=>null  //最终获得的数据
	];
		
	$sql="SELECT count(*) FROM picWhere";
	$result=mysqli_query($conn,$sql);
	$rows=mysqli_fetch_all($result,MYSQLI_ASSOC);
	$output["recordCount"]=$rows[0]["count(*)"];
	$output["pageCount"]=ceil($output["recordCount"]/$output["pageSize"]);
	
	$sql="select * from picWhere ";
	@$pno=$_REQUEST["pno"];
	if($pno){
		$output["pno"]=$pno;
		$start=$output["pageSize"]*($pno-1);
		$sql=$sql."limit $start,".$output["pageSize"];
	}
	$result=mysqli_query($conn,$sql);
	$rows=mysqli_fetch_all($result,MYSQLI_ASSOC);
	$output["data"]=$rows;
	echo json_encode(($output));